CentOS 6
Sponsored Link

Use mod_proxy#2
2014/09/15
 
Enable mod_proxy and configute httpd as a reverse proxy. This example is based on the environment below.
(1) www.srv.world   [10.0.0.31]   - Web Server#1
(2) dlp.srv.world   [10.0.0.30]   - Web Server#2
This example set servers that requests to Web server (1) forward to / on webserver (2)
[1] Configure httpd.
[root@www ~]#
vi /etc/httpd/conf.d/r_proxy.conf
# create new

<IfModule mod_proxy.c>
   ProxyRequests Off
   <Proxy *>
      Order deny,allow
      Allow from all
   </Proxy>
  
# destination server and directory

   ProxyPass / http://dlp.srv.world/
   ProxyPassReverse / http://dlp.srv.world/
</IfModule>
[root@www ~]#
/etc/rc.d/init.d/httpd restart

Stopping httpd:
[  OK  ]

Starting httpd:
[  OK  ]

  Access to / with any web browser from Clients and make sure backend server replys normally.
[2]
In addition to [1], it's possible to set load balancing function.
(1) www.srv.world      [10.0.0.31]   - Web Server#1
(2) www01.srv.world   [10.0.0.60]   - Web Server#2
(3) www02.srv.world   [10.0.0.61]   - Web Server#3
This example shows to configure servers that http requests to (1)'s webserver are forwarded to (2)'s webserver and (3)'s webserver.
[root@www ~]#
vi /etc/httpd/conf.d/r_proxy.conf
# create new

<IfModule mod_proxy.c>
   ProxyRequests Off
   <Proxy *>
      Order deny,allow
      Allow from all
   </Proxy>
  
# specify the way of load balancing with "lbmethod". it's also possible to set "bytraffic".

   ProxyPass / balancer://cluster lbmethod=byrequests
   <proxy balancer://cluster>
      BalancerMember http://www01.srv.world/ loadfactor=1
      BalancerMember http://www02.srv.world/ loadfactor=1
   </proxy>
</IfModule>
[root@www ~]#
/etc/rc.d/init.d/httpd restart

Stopping httpd:
[  OK  ]

Starting httpd:
[  OK  ]

  Access to /proxy, then backend server is answered as settings. Push update button on your browser without breake and make sure backend server switches normally.
 
Tweet